home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d12
/
cgazv5n5.arc
/
LZW.H
< prev
next >
Wrap
C/C++ Source or Header
|
1991-09-23
|
2KB
|
73 lines
/*--- LZW.H ------------------------------ Listing 1 ---
* Contents: Include file for LZW coding
* Author: Dwayne Phillips
* Compilers: Microsoft C 6.0a, BC++ 2.0
* Date: February 1991
* May be used freely if authorship is acknowledged
------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
/* buffer sizes for compression routines */
#define IB_LENGTH_C 500
#define OB_LENGTH_C 500
/* buffer sizes for decompression routines */
#define IB_LENGTH_D 500
#define OB_LENGTH_D 500
/* size of translation table */
#define TABLE_SIZE 4096
#define BASE_TABLE 255 /* these we initialize automatically */
/* LZW codes are stored in objects of this type */
typedef short code_type;
/*
This struct is used to build the string table:
num - the code of the item in the table upon which
this item is built.
character - the character appended onto the string in
the table.
*/
typedef struct tag_table_item {
code_type num;
code_type chain;
int character;
} table_item;
/* lzw1.c */
void compression_routine(table_item *, FILE *, FILE *);
void write_out_code(code_type, code_type *, unsigned *, FILE *);
code_type wk_is_in_table(unsigned char *, int, table_item *);
void put_wk_in_table(code_type, int,
table_item *, unsigned *);
void create_string(unsigned char *, int);
void build_string(unsigned char *, code_type, table_item *);
void append_char(unsigned char *, int);
unsigned initialize(table_item *);
/* lzw2.c */
void decompression_routine(table_item *, FILE *, FILE *);
unsigned read_compressed_file(short *, FILE *);
void update_table(int, unsigned char *, code_type *,
table_item *, unsigned *);
void output_char(int, unsigned char *, unsigned *, FILE *);
/* lzw3.c */
unsigned my_read ( FILE *, void *, size_t, size_t );
void my_write ( FILE *, void *, size_t, size_t );
#if defined(DEBUG)
/* lzw-test.c */
void print_string_table(table_item *, char *, int, int);
#define SHOW(x) x
#else
#define SHOW(x)
#endif